﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StockMarketTool.Helper
{
    public class AppSettingHelper
    {
        public static T GetValue<T>(string settingKey, T defaultvalue= default(T))
        {
            try
            {
                string settingValueString = ConfigurationManager.AppSettings[settingKey];
                if (!string.IsNullOrEmpty(settingValueString))
                {
                    T result = default(T);
                    result = (T)Convert.ChangeType(settingValueString, typeof(T));
                    return result;
                }
            }
            catch //(Exception ex)
            {
            }

            return defaultvalue;
        }
    }
}
